home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8"?>
- <xsl:stylesheet version="1.0"
- xmlns:msxsl="urn:schemas-microsoft-com:xslt"
- xmlns:roboml="urn:schemas-ehelp-com:xslt"
- xmlns:RHHandlerDb="http://ehelp.com/RHHandlerDb"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:html="http://www.w3.org/1999/xhtml"
- exclude-result-prefixes="roboml msxsl RHHandlerDb xsl html">
-
- <xsl:output method="xml" encoding="utf-8" indent="yes"/>
-
- <!-- parameters -->
- <xsl:param name="roboxml_source_file_name">safari.xml</xsl:param>
- <xsl:param name="roboxml_destination_file_name">aaa.xml</xsl:param>
- <xsl:param name="roboxml_source_dir_name">c:\\Tmp\\Sample\\_Output\\3\\</xsl:param>
- <xsl:param name="roboxml_destination_dir_name">c:\\Tmp\\Sample\\_Output\\3\\1\\</xsl:param>
- <xsl:param name="roboxml_progress_file_name">__status__.xml</xsl:param>
- <xsl:param name="roboxml_preserve_white_space">true</xsl:param>
- <xsl:param name="roboxml_resolve_externals">false</xsl:param>
- <xsl:param name="roboxml_language_name">English</xsl:param>
- <xsl:param name="export.comment">1</xsl:param>
- <xsl:param name="export.style">1</xsl:param>
- <xsl:param name="export.script">1</xsl:param>
-
- <xsl:param name="cleanup.xhtmlfiles" select="0" />
- <!-- includings -->
- <xsl:include href="./common/rhc_l10n.xsl"/> <!-- language -->
- <xsl:include href="PRJ2DOCBOOKUTILS.xsl"/> <!-- utility template and script functions -->
-
- <!-- ================= Script defines here =========================== -->
- <msxsl:script language="JScript" implements-prefix="RHHandlerDb">
-
- function wellFormedPath( pathName, fileName )
- {
- var regExp = new RegExp("/", "g");
- var srcPath = pathName.replace(regExp, "\\") ;
-
- if (srcPath.length > 0)
- {
- if (srcPath.charAt(srcPath.length-1) != "\\") srcPath += "\\" ;
- }
- srcPath += fileName ;
-
- return srcPath.replace(regExp, "\\") ;
- }
-
- function getTransformedURL( srcURL )
- {
- var newURL = wellFormedPath("", srcURL) ;
- var transURL = getXmlfilenameFromHtm ( newURL, "\\") ;
-
- var regExp = /\\/g ;
- transURL = transURL.replace(regExp, "/") ;
-
- return transURL ;
- }
-
- function updateProcessStatusFile(dstPath, progressfilename, strDoing, nTotalFiles, nCurrentFile)
- {
- try
- {
- var strStatus ;
- strStatus = "<?xml version=\"1.0\" ?>" ;
- strStatus = strStatus + "<status><doing>" + strDoing + "</doing>" ;
- strStatus = strStatus + "<total>" + nTotalFiles + "</total>" ;
- strStatus = strStatus + "<current>" + nCurrentFile + "</current></status>" ;
-
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var fileName = wellFormedPath(dstPath, progressfilename) ;
- var pgsFile = fso.CreateTextFile(fileName, true);
-
- pgsFile.WriteLine(strStatus);
- pgsFile.Close();
-
- }
- catch(e)
- {
- return "ERROR: " + e ;
- }
- return "" ;
- }
-
- function rhcLangID_To_DocBookLangID(strRhcLangID)
- {
- if(strRhcLangID == "English") return "en";
- else if(strRhcLangID == "Dansk") return "da";
- else if(strRhcLangID == "Deutsch") return "de";
- else if(strRhcLangID == "Espa├▒ol") return "es";
- else if(strRhcLangID == "Français") return "fr";
- else if(strRhcLangID == "Italiano") return "it";
- else if(strRhcLangID == "Nederlands") return "nl";
- else if(strRhcLangID == "Norsk") return "no";
- else if(strRhcLangID == "Português(Brasil)") return "pt_br";
- else if(strRhcLangID == "Português(Portugal)") return "pt";
- else if(strRhcLangID == "Svenska") return "sv";
- return "en";
- }
-
- function xml2Docbook(dstPath, srcPath, xmldocname, xsldocname,
- prjfilename, strTopicExportFlags, bPreserveWhiteSpace, bResolveExternals, strLanguage)
- {
- try
- {
- var srcDocName = wellFormedPath( srcPath, xmldocname ) ;
- var prjDocName = prjfilename ; // prjfilename is a full-path filename
- var dstDocName = wellFormedPath( dstPath, xmldocname ) ;
- dstDocName = getXmlfilenameFromHtm( dstDocName, "\\") ;
-
- var xmldoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");
- var xsldoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");
- var output = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");
- var xslt = new ActiveXObject("Msxml2.XSLTemplate.4.0");
-
- xmldoc.preserveWhiteSpace = bPreserveWhiteSpace ;
- output.preserveWhiteSpace = bPreserveWhiteSpace ;
-
- xmldoc.async = false;
- xmldoc.validateOnParse = false;
- xmldoc.resolveExternals = bResolveExternals;
- xmldoc.load( srcDocName );
-
- xsldoc.async = false;
- xsldoc.validateOnParse = false;
- xsldoc.resolveExternals = bResolveExternals ;
- xsldoc.load( xsldocname );
-
- xslt.stylesheet = xsldoc;
-
- var xslProc = xslt.createProcessor();
- xslProc.input = xmldoc;
- xslProc.output = output;
-
- xslProc.addParameter("roboxml_destination_dir_name", wellFormedPath(dstPath,""));
- xslProc.addParameter("roboxml_project_file_name", prjDocName);
- xslProc.addParameter("rhc_language_name", rhcLangID_To_DocBookLangID(strLanguage));
-
-
- if (strTopicExportFlags.length>=3)
- {
- xslProc.addParameter("export.comment", strTopicExportFlags.charAt(0));
- xslProc.addParameter("export.script", strTopicExportFlags.charAt(1));
- xslProc.addParameter("export.style", strTopicExportFlags.charAt(2));
- }
-
- xslProc.transform();
- output.save(dstDocName);
- }
- catch(e)
- {
- throw e ;
- return "ERROR: " + e ;
- }
- return "" ;
- }
- </msxsl:script>
-
- <!-- templates start here -->
- <xsl:template match="/roboml">
- <appendix>
- <appendixinfo>
- <xsl:call-template name="generate_publisher_info">
- <xsl:with-param name="rootnode" select="." />
- </xsl:call-template>
- </appendixinfo>
-
- <title>
- <xsl:variable name="projtitle">
- <xsl:call-template name="gentext">
- <xsl:with-param name="key" select="'rhc.template.prjtitle'"/>
- <xsl:with-param name="lang" select="RHHandlerDb:rhcLangID_To_DocBookLangID(string($roboxml_language_name))"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:value-of select="$projtitle" />
- </title>
-
- <xsl:variable name="totalprojectfiles" select="count(project_files/*)" />
- <xsl:variable name="totalfiles" select="count(./project_files/*|./topics/topic)" />
- <xsl:call-template name="process_project_files">
- <xsl:with-param name="totalfiles" select="$totalfiles" />
- </xsl:call-template>
-
- <xsl:call-template name="process_topics">
- <xsl:with-param name="totalfiles" select="$totalfiles" />
- <xsl:with-param name="totalprojectfiles" select="$totalprojectfiles" />
- </xsl:call-template>
-
- <xsl:apply-templates select="comment()"/>
-
- </appendix>
- </xsl:template>
-
- <xsl:template name="process_project_files">
- <xsl:param name="totalfiles" select="1" />
- <section>
- <title>
- <xsl:call-template name="gentext">
- <xsl:with-param name="key" select="'rhc.projectfiles'" />
- <xsl:with-param name="lang" select="RHHandlerDb:rhcLangID_To_DocBookLangID(string($roboxml_language_name))"/>
- </xsl:call-template>
- </title>
- <itemizedlist>
- <xsl:for-each select="./project_files/*">
- <xsl:variable name="doing" select="concat('Transforming ', ./@url, ' ...')" />
- <xsl:variable name="current" select="position()" />
- <xsl:variable name="errMsg">
- <xsl:value-of select="RHHandlerDb:updateProcessStatusFile(string($roboxml_destination_dir_name),
- string($roboxml_progress_file_name), string($doing), string($totalfiles), string($current))" />
- </xsl:variable>
- <xsl:if test="$errMsg != ''">
- <xsl:comment><xsl:value-of select="concat('Error occurs in writing progress data[', $errMsg, ']')"/></xsl:comment>
- </xsl:if>
-
- <xsl:apply-templates select="." />
- </xsl:for-each>
- </itemizedlist>
- </section>
- </xsl:template>
-
- <xsl:template name="process_topics">
- <xsl:param name="totalfiles" select="1" />
- <xsl:param name="totalprojectfiles" select="0" />
- <section>
- <title>
- <xsl:call-template name="gentext">
- <xsl:with-param name="key" select="'rhc.topicfiles'" />
- <xsl:with-param name="lang" select="RHHandlerDb:rhcLangID_To_DocBookLangID(string($roboxml_language_name))"/>
- </xsl:call-template>
- </title>
- <itemizedlist>
- <xsl:for-each select="./topics/topic">
- <xsl:variable name="doing" select="concat('Transforming topic ', @url, ' ...')" />
- <xsl:variable name="current" select="number($totalprojectfiles) + position()" />
- <xsl:variable name="errMsg">
- <xsl:value-of select="RHHandlerDb:updateProcessStatusFile(string($roboxml_destination_dir_name),
- string($roboxml_progress_file_name), string($doing), string($totalfiles), string($current))" />
- </xsl:variable>
- <xsl:if test="$errMsg != ''">
- <xsl:comment><xsl:value-of select="concat('Error found while writing progress data[', $errMsg, ']')"/></xsl:comment>
- </xsl:if>
-
- <xsl:apply-templates select="." />
- </xsl:for-each>
- </itemizedlist>
- </section>
- </xsl:template>
-
- <xsl:template name="generate_file_url">
- <xsl:param name="url" select="''" />
- <xsl:param name="title" select="''" />
-
- <xsl:variable name="transformedURL">
- <xsl:value-of select="RHHandlerDb:getTransformedURL(string($url))" />
- </xsl:variable>
-
- <para>
- <ulink>
- <xsl:attribute name="url">
- <xsl:value-of select="$transformedURL" />
- </xsl:attribute>
- <xsl:choose>
- <xsl:when test="normalize-space($title) != ''">
- <xsl:value-of select="$title" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$transformedURL" />
- </xsl:otherwise>
- </xsl:choose>
- </ulink>
- </para>
- </xsl:template>
-
- <xsl:template match="toc[normalize-space(@url)!= '']">
- <listitem role="toc">
- <xsl:variable name="errMsg">
- <xsl:value-of select="RHHandlerDb:xml2Docbook(string($roboxml_destination_dir_name),string($roboxml_source_dir_name),
- string(@url),'toc2docbook.xsl',string($roboxml_source_file_name),'',
- $roboxml_preserve_white_space, $roboxml_resolve_externals,string($roboxml_language_name))" />
- </xsl:variable>
- <xsl:if test="$errMsg != ''">
- <xsl:comment><xsl:value-of select="concat('Error occurs in transforming[', $errMsg, ']')"/></xsl:comment>
- </xsl:if>
- <xsl:call-template name="generate_file_url">
- <xsl:with-param name="url" select="@url" />
- <xsl:with-param name="title">
- <xsl:call-template name="gentext">
- <xsl:with-param name="key" select="'rhc.tableofcontents'" />
- <xsl:with-param name="lang" select="RHHandlerDb:rhcLangID_To_DocBookLangID(string($roboxml_language_name))"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </listitem>
- </xsl:template>
-
- <!-- keyword index -->
- <xsl:template match="index[normalize-space(@url)!= '' and @type='keyword']">
- <listitem role="keyword">
- <xsl:variable name="errMsg">
- <xsl:value-of select="RHHandlerDb:xml2Docbook(string($roboxml_destination_dir_name),string($roboxml_source_dir_name),
- string(@url),'index2docbook.xsl',string($roboxml_source_file_name),'',
- $roboxml_preserve_white_space, $roboxml_resolve_externals,string($roboxml_language_name))" />
- </xsl:variable>
- <xsl:if test="$errMsg != ''">
- <xsl:comment><xsl:value-of select="concat('Error occurs in transforming[', $errMsg, ']')"/></xsl:comment>
- </xsl:if>
- <xsl:call-template name="generate_file_url">
- <xsl:with-param name="url" select="@url" />
- <xsl:with-param name="title">
- <xsl:call-template name="gentext">
- <xsl:with-param name="key" select="'rhc.keywordindex'" />
- <xsl:with-param name="lang" select="RHHandlerDb:rhcLangID_To_DocBookLangID(string($roboxml_language_name))"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </listitem>
- </xsl:template>
-
- <!-- see also index -->
- <xsl:template match="index[normalize-space(@url)!= '' and @type='see also']">
- <listitem role="seealso">
- <xsl:variable name="errMsg">
- <xsl:value-of select="RHHandlerDb:xml2Docbook(string($roboxml_destination_dir_name),string($roboxml_source_dir_name),
- string(@url),'seealso2docbook.xsl',string($roboxml_source_file_name),'',
- $roboxml_preserve_white_space, $roboxml_resolve_externals,string($roboxml_language_name))" />
- </xsl:variable>
- <xsl:if test="$errMsg != ''">
- <xsl:comment><xsl:value-of select="concat('Error occurs in transforming[', $errMsg, ']')"/></xsl:comment>
- </xsl:if>
- <xsl:call-template name="generate_file_url">
- <xsl:with-param name="url" select="@url" />
- <xsl:with-param name="title">
- <xsl:call-template name="gentext">
- <xsl:with-param name="key" select="'rhc.seealsoindex'" />
- <xsl:with-param name="lang" select="RHHandlerDb:rhcLangID_To_DocBookLangID(string($roboxml_language_name))"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </listitem>
- </xsl:template>
-
- <!-- glossary -->
- <xsl:template match="gls[normalize-space(@url)!= '']">
- <listitem role="gls">
- <xsl:variable name="errMsg">
- <xsl:value-of select="RHHandlerDb:xml2Docbook(string($roboxml_destination_dir_name),string($roboxml_source_dir_name),
- string(@url),'glossary2docbook.xsl',string($roboxml_source_file_name),'',
- $roboxml_preserve_white_space, $roboxml_resolve_externals,string($roboxml_language_name))" />
- </xsl:variable>
- <xsl:if test="$errMsg != ''">
- <xsl:comment><xsl:value-of select="concat('Error occurs in transforming[', $errMsg, ']')"/></xsl:comment>
- </xsl:if>
-
- <xsl:call-template name="generate_file_url">
- <xsl:with-param name="url" select="@url" />
- <xsl:with-param name="title">
- <xsl:call-template name="gentext">
- <xsl:with-param name="key" select="'rhc.glossary'" />
- <xsl:with-param name="lang" select="RHHandlerDb:rhcLangID_To_DocBookLangID(string($roboxml_language_name))"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </listitem>
- </xsl:template>
-
- <!-- browse sequence -->
- <xsl:template match="brs[normalize-space(@url)!= '']">
- <listitem role="brs">
- <xsl:variable name="errMsg">
- <xsl:value-of select="RHHandlerDb:xml2Docbook(string($roboxml_destination_dir_name),string($roboxml_source_dir_name),
- string(@url),'brs2docbook.xsl',string($roboxml_source_file_name),'',
- $roboxml_preserve_white_space, $roboxml_resolve_externals,string($roboxml_language_name))" />
- </xsl:variable>
- <xsl:if test="$errMsg != ''">
- <xsl:comment><xsl:value-of select="concat('Error occurs in transforming[', $errMsg, ']')"/></xsl:comment>
- </xsl:if>
- <xsl:call-template name="generate_file_url">
- <xsl:with-param name="url" select="@url" />
- <xsl:with-param name="title">
- <xsl:call-template name="gentext">
- <xsl:with-param name="key" select="'rhc.browsesequence'" />
- <xsl:with-param name="lang" select="RHHandlerDb:rhcLangID_To_DocBookLangID(string($roboxml_language_name))"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </listitem>
- </xsl:template>
-
- <!-- topics -->
- <xsl:template match="topic[normalize-space(@url)!= '']">
- <xsl:variable name="TopicExportFlags">
- <xsl:value-of select="concat($export.comment, $export.script, $export.style)"/>
- </xsl:variable>
- <listitem>
- <xsl:variable name="errMsg">
- <xsl:value-of select="RHHandlerDb:xml2Docbook(string($roboxml_destination_dir_name),string($roboxml_source_dir_name),
- string(@url),'xhtml2docbook.xsl',string($roboxml_source_file_name), string($TopicExportFlags),
- $roboxml_preserve_white_space, $roboxml_resolve_externals,string($roboxml_language_name))" />
- </xsl:variable>
- <xsl:if test="$errMsg != ''">
- <xsl:comment><xsl:value-of select="concat('Error occurs in transforming[', $errMsg, ']')"/></xsl:comment>
- </xsl:if>
- <xsl:call-template name="generate_file_url">
- <xsl:with-param name="url" select="@url" />
- <xsl:with-param name="title" select="@title" />
- </xsl:call-template>
- </listitem>
- </xsl:template>
-
- <xsl:template match="comment()">
- <xsl:copy />
- </xsl:template>
-
- </xsl:stylesheet>
-